package com.bwie.coupon.service.impl;

import com.bwie.common.core.domain.R;
import com.bwie.common.core.domain.Result;
import com.bwie.coupon.domain.po.MlCoupon;
import com.bwie.coupon.domain.po.MlSeller;
import com.bwie.coupon.domain.po.PmsSkuInfo;
import com.bwie.coupon.domain.vo.MlCouponVo;
import com.bwie.coupon.mapper.MlCouponMapper;
import com.bwie.coupon.mapper.MlSellerMapper;
import com.bwie.coupon.service.MlSellerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MlSellerServiceImpl implements MlSellerService {
    @Autowired
    private MlSellerMapper mlSellerMapper;

  @Autowired
  private MlCouponMapper mlCouponMapper;
    /**
     * 商家下的所有优惠卷
     *
     * @return
     */
    @Override
    public Result<List<MlSeller>> selectMlSeller(Long sellerId) {
        List<MlSeller> mlSellers = mlSellerMapper.selectMlSeller(sellerId);
        for (MlSeller mlSeller : mlSellers) {
            List<PmsSkuInfo> pmsSkuInfos = mlSeller.getPmsSkuInfos();
            for (PmsSkuInfo pmsSkuInfo : pmsSkuInfos) {
                Long sellerId1 = pmsSkuInfo.getSellerId();
                List<MlCoupon> mlCoupons = mlCouponMapper.selectMlCouponList(sellerId1);
                mlSeller.setCouponList(mlCoupons);
            }
        }
        return Result.success(mlSellers);
    }




}
